<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新版本数据导入主页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="Public/Plug/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="Public/Static/Home/css/main.css" media="all"/>
    <style>
        .layui-upload-file {
            display: none;
        }
        .margin-1{
            margin-top: 20px;
        }
        .dl-title-mar{
            margin-top: 10px;
            margin-bottom: 10px;
        }
        .marleft-2{
            margin-left: 30px;
        }
        .json-pz-title{
            font-size: 18px;
            color: #333333;
        }
        .jsonfile-pz{
            color: red;
            margin-bottom: 10px;
            margin-left: 30px;
            margin-top: 10px;
        }
        .delInp{
            width: 7px;
            height: 22px;
            padding: 0px 5px;
            margin-left: 10px;
            background-color: #009688;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            border-radius: 2px;
            cursor: pointer;
            opacity: .9;
            display: inline-block;
        }
        .delbtn{
            width: 7px;
            height: 22px;
            padding: 0px 5px;
            background-color: #009688;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            border-radius: 2px;
            cursor: pointer;
            opacity: .9;
            display: inline-block;
        }
        .tmoba-content{
            margin-bottom: 10px;
            position: relative;
        }
    </style>
</head>
<body class="childrenBody">
<div style="padding: 20px 10px;width: 100%;height: 40px;">
    当前资料库对应版本{$versionNumber}, 可切换到
    <div style="display: inline-block;" class="layui-form-item">
        <select id="testSelect" name="versionNum" lay-verify="required">
            {foreach $resTotal as $val}
            <option value="{$val.id}">{$val.versionNumber}</option>
            {/foreach}
        </select>
    </div>
    <button style="margin-left: 20px;" class="layui-btn rollback">切换</button>
    {if $isExistsVersion == true}
    <button style="margin-left: 10px;" class="layui-btn copy">复制版本</button>
    <button style="margin-left: 20%;" class="layui-btn layui-btn-danger makeAllJs">生成全部js</button>
    {/if}
</div>
<div style="margin-bottom: 50px;width: 80%;" class="layui-collapse">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">版本数据导入前配置</h2>
        <div class="layui-colla-content">
            <div class="layui-row">
              <div class="layui-col-md12">
                  <div class="json-pz-title">{$itemsFilter.name}</div>
                  <div class="jsonfile-pz marleft-2">{$itemsFilter.description}(请用,号隔开)</div>
                  <div class="layui-form-item layui-form-text marleft-2">
                      <div style="margin-left: 0px;margin-top: 10px;" class="layui-input-block">
                          <textarea name="itemsFilterValue" id="itemsFilterValue" placeholder="请输入内容" class="layui-textarea" value="{$itemsFilter.value}">{$itemsFilter.value}</textarea>
                      </div>
                  </div>
              </div>
            </div>
            <div style="width: 100%;padding: 0px;" class="layui-container">
                <p class="json-pz-title">JSON文件匹配规则</p>
                <div class="jsonfile-pz">系统将根据这个规则来检测json文件的类型</div>
                <div class="layui-row margin-1">
                    <div class="dl-title-mar json-pz-title">
                        TMOBA版本
                    </div>
                    <div class="marleft-2">
                        <div class="tmoba-content">
                            <div class="layui-col-row">
                                <span style="display: inline-block;line-height: 38px;">英雄tmoba数据</span>
                                <div style="display: inline-block;margin-bottom: 0px;" class="layui-form-item">
                                    <div style="margin-left: 10px;" class="layui-input-block">
                                        <select style="line-height: 38px;" id="heroTmoba" lay-verify="required">
                                            <option value="1" {if $heroTmobaType == 1} selected {/if}>检测key是否存在</option>
                                            <option value="2" {if $heroTmobaType == 2} selected {/if}>检测key=值</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {if count($heroTmobaKeys) == 0}
                            <div class="layui-col-row">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroTmobaInput">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroTmobaInput"><button style="display: none;height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs heroTmobaBtn">+</button>
                            </div>
                            {else}
                                {foreach $heroTmobaKeys as $key=>$val}
                                <div class="layui-col-row">
                                    {if $val@first}
                                        <input style="display: {if $heroTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroTmobaInput" value="{$key}">
                                        <input style="display: {if $heroTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroTmobaInput" value="{$val}"><button style="display: {if $heroTmobaType == 2} inline-block {else} none {/if};height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs heroTmobaBtn">+</button>
                                    {else}
                                    <div class="layui-col-row">
                                        <input style="display: {if $heroTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroTmobaInput" value="{$key}">
                                        <input style="display: {if $heroTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroTmobaInput" value="{$val}"><i style="margin-left: 10px;" class="delbtn">-</i>
                                    </div>
                                    {/if}
                                </div>
                                {/foreach}
                            {/if}
                            <div class="heroTmobaAdd"></div>
                            <div class="jsonHeroTmobaTips" style="color:red;display:  {if $heroTmobaType == 1} inline-block {else} none {/if};">检验英雄Tmoba中json文件里的(请用,号隔开)</div>
                            <textarea style="display:  {if $heroTmobaType == 1} inline-block {else} none {/if};" name="desc" placeholder="请输入内容" id="heroTmobaTextArea" class="layui-textarea heroTmobaTextArea">{$heroTmobaTextArea}</textarea>
                        </div>

                        <div style="margin-bottom: 10px;">
                            <div class="layui-col-row">
                                <span style="display: inline-block;line-height: 38px;">道具tmoba数据</span>
                                <div style="display: inline-block;margin-bottom: 0px;" class="layui-form-item">
                                    <div style="margin-left: 10px;" class="layui-input-block">
                                        <select id="itemsTmoba" lay-verify="required">
                                            <option value="1" {if $itemsTmobaType == 1} selected {/if}>检测key是否存在</option>
                                            <option value="2" {if $itemsTmobaType == 2} selected {/if}>检测key=值</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {if count($itemsTmobaKeys) == 0}
                            <div class="layui-col-row">
                                 <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsTmobaInput">
                                 <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsTmobaInput"><button style="display: none;height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs itemsTmobaBtn">+</button>
                            </div>
                            {else}
                                {foreach $itemsTmobaKeys as $key=>$val}
                                <div class="layui-col-row">
                                    {if $val@first}
                                    <input style="display: {if $itemsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsTmobaInput" value="{$key}">
                                    <input style="display: {if $itemsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsTmobaInput" value="{$val}"><button style="display: {if $itemsTmobaType == 2} inline-block {else} none {/if};height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs itemsTmobaBtn">+</button>
                                    {else}
                                    <div class="layui-col-row">
                                        <input style="display: {if $itemsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsTmobaInput" value="{$key}">
                                        <input style="display: {if $itemsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsTmobaInput" value="{$val}"><i style="margin-left: 10px;" class="delbtn">-</i>
                                    </div>
                                    {/if}
                                </div>
                                {/foreach}
                            {/if}
                            <div class="itemsTmobaAdd"></div>
                            <div class="jsonItemsTmobaTips" style="color:red;display: {if $itemsTmobaType == 1} inline-block {else} none {/if};">检验道具Tmoba中json文件里的(请用,号隔开)</div>
                            <textarea style="display: {if $itemsTmobaType == 1} inline-block {else} none {/if};" name="desc" placeholder="请输入内容" id="itemsTmobaTextArea" class="layui-textarea itemsTmobaTextArea">{$itemsTmobaTextArea}</textarea>
                        </div>
                        <div style="margin-bottom: 10px;">
                            <div class="layui-col-row">
                                <span style="display: inline-block;line-height: 38px;">皮肤tmoba数据</span>
                                <div style="display: inline-block;margin-bottom: 0px;" class="layui-form-item">
                                    <div style="margin-left: 10px;" class="layui-input-block">
                                        <select id="skinsTmoba" lay-verify="required">
                                            <option value="1" {if $skinsTmobaType == 1} selected {/if}>检测key是否存在</option>
                                            <option value="2" {if $skinsTmobaType == 2} selected {/if}>检测key=值</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {if count($skinsTmobaKeys) == 0}
                            <div class="layui-col-row">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input skinsTmobaInput">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input skinsTmobaInput"><button style="display: none;height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs skinsTmobaBtn">+</button>
                            </div>
                            {else}
                            {foreach $skinsTmobaKeys as $key=>$val}
                            <div class="layui-col-row">
                                {if $val@first}
                                <input style="display: {if $skinsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input skinsTmobaInput" value="{$key}">
                                <input style="display: {if $skinsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input skinsTmobaInput" value="{$val}"><button style="display: {if $skinsTmobaType == 2} inline-block {else} none {/if};height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs skinsTmobaBtn">+</button>
                                {else}
                                <div class="layui-col-row">
                                    <input style="display: {if $skinsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input skinsTmobaInput" value="{$key}">
                                    <input style="display: {if $skinsTmobaType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="skinsTmobaValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input skinsTmobaInput" value="{$val}"><i style="margin-left: 10px;" class="delbtn">-</i>
                                </div>
                                {/if}
                            </div>
                            {/foreach}
                            {/if}
                            <div class="skinsTmobaAdd"></div>
                            <div class="jsonSkinsTmobaTips" style="color:red;display: {if $skinsTmobaType == 1} inline-block {else} none {/if};">检验皮肤Tmoba中json文件里的(请用,号隔开)</div>
                            <textarea style="display: {if $skinsTmobaType == 1} inline-block {else} none {/if};" name="desc" placeholder="请输入内容" id="skinsTmobaTextArea" class="layui-textarea skinsTmobaTextArea">{$skinsTmobaTextArea}</textarea>
                        </div>
                    </div>
                </div>
                <hr/>
                <div class="layui-row margin-1">
                    <div class="dl-title-mar json-pz-title">
                        JSON版本
                    </div>
                    <div class="layui-col-md10 marleft-2">
                        <div style="margin-bottom: 10px;">
                            <div class="layui-col-row">
                                <span style="display: inline-block;line-height: 38px;">英雄json数据</span>
                                <div style="display: inline-block;margin-bottom: 0px;" class="layui-form-item">
                                    <div style="margin-left: 10px;" class="layui-input-block">
                                        <select id="heroJson" lay-verify="required">
                                            <option value="1" {if $heroJsonType == 1} selected {/if}>检测key是否存在</option>
                                            <option value="2" {if $heroJsonType == 2} selected {/if}>检测key=值</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {if count($heroJsonKeys) == 0}
                                <div class="layui-col-row">
                                    <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroJsonInput">
                                    <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroJsonInput"><button style="display: none;height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs heroJsonBtn">+</button>
                                </div>
                            {else}
                            {foreach $heroJsonKeys as $key=>$val}
                                <div class="layui-col-row">
                                    {if $val@first}
                                    <input style="display: {if $heroJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroJsonInput" value="{$key}">
                                    <input style="display: {if $heroJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroJsonInput" value="{$val}"><button style="display: {if $heroJsonType == 2} inline-block {else} none {/if};height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs heroJsonBtn">+</button>
                                    {else}
                                    <div class="layui-col-row">
                                        <input style="display: {if $heroJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input heroJsonInput" value="{$key}">
                                        <input style="display: {if $heroJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="heroJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input heroJsonInput" value="{$val}"><i style="margin-left: 10px;" class="delbtn">-</i>
                                    </div>
                                    {/if}
                                </div>
                            {/foreach}
                            {/if}
                            <div class="heroJsonAdd"></div>
                            <div class="jsonHeroJsonTips" style="color:red;display: {if $heroJsonType == 1} inline-block {else} none {/if};">检验英雄Json中json文件里的(请用,号隔开)</div>
                            <textarea style="display: {if $heroJsonType == 1} inline-block {else} none {/if};" name="desc" placeholder="请输入内容" id="heroJsonTextArea" class="layui-textarea heroJsonTextArea">{$heroJsonTextArea}</textarea>
                        </div>
                        <div style="margin-bottom: 10px;">
                            <div class="layui-col-row">
                                <span style="display: inline-block;line-height: 38px;">道具json数据</span>
                                <div style="display: inline-block;margin-bottom: 0px;" class="layui-form-item">
                                    <div style="margin-left: 10px;" class="layui-input-block">
                                        <select id="itemsJson" lay-verify="required">
                                            <option value="1" {if $itemsJsonType == 1} selected {/if}>检测key是否存在</option>
                                            <option value="2" {if $itemsJsonType == 2} selected {/if}>检测key=值</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {if count($itemsJsonKeys) == 0}
                            <div class="layui-col-row">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsJsonInput">
                                <input style="display: none;width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsJsonInput"><button style="display: none;height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs itemsJsonBtn">+</button>
                            </div>
                            {else}
                            {foreach $itemsJsonKeys as $key=>$val}
                            <div class="layui-col-row">
                                {if $val@first}
                                <input style="display: {if $itemsJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsJsonInput" value="{$key}">
                                <input style="display: {if $itemsJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsJsonInput" value="{$val}"><button style="display: {if $itemsJsonType == 2} inline-block {else} none {/if};height: 22px;line-height: 22px;padding: 0 5px;font-size: 12px;margin-left: 10px;" class="layui-btn layui-btn-xs itemsJsonBtn">+</button>
                                {else}
                                <div class="layui-col-row">
                                    <input style="display: {if $itemsJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonKey" required  lay-verify="required" placeholder="请输入Key值" autocomplete="off" class="layui-input itemsJsonInput" value="{$key}">
                                    <input style="display: {if $itemsJsonType == 2} inline-block {else} none {/if};width: 25%;margin: 0px 0px 10px 10px;" type="text" name="itemsJsonValue" required  lay-verify="required" placeholder="请输入Value值" autocomplete="off" class="layui-input itemsJsonInput" value="{$val}"><i style="margin-left: 10px;" class="delbtn">-</i>
                                </div>
                                {/if}
                            </div>
                            {/foreach}
                            {/if}
                            <div class="itemsJsonAdd"></div>
                            <div class="jsonItemsJsonTips" style="color:red;display: {if $itemsJsonType == 1} inline-block {else} none {/if};">检验道具Json中json文件里的(请用,号隔开)</div>
                            <textarea style="display: {if $itemsJsonType == 1} inline-block {else} none {/if};" name="desc" placeholder="请输入内容" id="itemsJsonTextArea" class="layui-textarea itemsJsonTextArea">{$itemsJsonTextArea}</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center;">
                <div style="margin-left: 0px;" class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
<fieldset style="width: 80%;" class="layui-elem-field">
    <legend>TMOBA/JSON版本数据</legend>
    <div class="layui-field-box">
        <div style="width: 100%;height: 60px;padding: 0px 0px 10px 30px;">
            <div style="display: inline-block;width: 47%;">
                <input id="input-tmoba" style="width: 600px;" type="text" name="" placeholder="上传最新的Json文件"
                       autocomplete="off" class="layui-input">
            </div>
            <div style="display: inline-block;">
                <button type="button" class="layui-btn" id="test">
                    浏览
                </button>
                <button style="display: inline-block;" class="layui-btn" id="tmobaListAction">
                    导入
                </button>
            </div>
        </div>
        <div style="margin-left: 30px;" class="layui-upload-list">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>文件名</th>
                    <th>大小</th>
                    <th>状态</th>
                    <th>详情</th>
                </tr>
                </thead>
                <tbody id="tmobaList"></tbody>
            </table>
        </div>
        <input type="hidden" name="json_dir" value="{$json_dir}" id="json_dir">
        <input type="hidden" name="save_dir" value="{$saveDir}" id="save_dir">
        <div style="padding: 30px 0px 30px 30px;" class="layui-row">
            <button class="layui-btn update" lay-data="TombaJson">更新到数据库</button>
        </div>
    </div>
</fieldset>
<script type="text/javascript" src="Public/Plug/layui/layui.all.js"></script>
<script type="text/javascript" src="Public/Static/Home/js/main.js"></script>
<script>
    layui.use(['element', 'upload','form'], function () {
        var $ = layui.jquery,
            element = layui.element,
            form = layui.form
            upload = layui.upload;
        var save_dir = $('#save_dir').val();
        //多文件列表示例
        var demoListView = $('#tmobaList')
            , uploadListIns = upload.render({
            elem: '#test'
            , url: "{U('LolApi/uploadJson')}"+'&save_dir='+save_dir
            , accept: 'file'
            , multiple: true
            , auto: false
            , bindAction: '#tmobaListAction'
            , choose: function (obj) {
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function (index, file, result) {
                    var tr = $(['<tr id="upload-' + index + '">'
                        , '<td>' + file.name + '</td>'
                        , '<td>' + (file.size / 1014).toFixed(2) + 'kb</td>'
                        , '<td>等待上传</td>'
                        , '<td>'
                        , '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                        , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                        , '</td>'
                        , '</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function () {
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function () {
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });
                    demoListView.append(tr);
                });
            }
            , before: function(){
                var text = $('#tmobaList').text();
                if(text.length === 0){
                    layer.msg("请先选择文件，再点击导入", {
                        icon: 2,
                        time: 2000
                    });
                    return;
                }
                layer.load(); //上传loading
            }
            , done: function (res, index, upload) {
                layer.closeAll('loading'); //关闭loading
                if (res.code === 0) { //上传成功
                    //写入文件的路径到前端
                    $('#json_dir').val(res.dir);
                    var tr = demoListView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html('<span style="color: #FF5722;">' + res.change_msg + '</span>'); //清空操作
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                } else if (res.code === 404) { //上传成功 文件不符合 删除文件
                    //写入文件的路径到前端
                    var tr = demoListView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #FF5722;">' + res.msg + '</span>');
                    tds.eq(3).html('<span style="color: #FF5722;">' + res.change_msg + '</span>'); //清空操作
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                } else {
                    layer.msg(res.msg, {
                        icon: 2,
                        time: 2000
                    });
                }
                this.error(index, upload);
            }
            , error: function (index, upload) {
                layer.closeAll('loading'); //关闭loading
                var tr = demoListView.find('tr#upload-' + index)
                    , tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
        //切换版本
        $(".rollback").on("click",function () {
            layer.confirm('确定切换至此版本？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //获取Id
                var id = $('#testSelect option:selected') .val();//索引
                var versionNum = $('#testSelect option:selected') .text();
                //按钮【按钮一】的回调
                var url = "{U('Version/switchVersion')}";
                $.ajax({
                    url: url, type: "post", dataType: "json",
                    data: { id:id,versionNumber: versionNum},
                    beforeSend:function () {
                        this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
                    },
                    success:function(data){
                        if(data.status =="error"){
                            layer.msg(data.msg);//失败的表情
                            return;
                        }else if(data.status == "success"){
                            layer.msg(data.msg, {
                                icon: 1,//成功的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                top.location.reload();
                            });
                        }
                    },
                    complete: function () {
                        layer.close(this.layerIndex);
                    },
                });

            });
        });
        $(".makeAllJs").on("click",function () {
            layer.confirm('确认生成当前版本已发布数据js文件?',{
                title: '提示信息',
                btn: ['确定', '取消']
            }, function(index, layero){
                //do something
                //按钮【按钮一】的回调
                var url = "{U('LolApi/makeAllJs')}";
                $.ajax({
                    url: url, type: "post", dataType: "json",
                    beforeSend:function () {
                        this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
                    },
                    success:function(data){
                        layer.closeAll('dialog');  //加入这个信息点击确定 会关闭这个消息框
                        if(data.code === 1){
                            layer.msg(data.msg,{
                                icon: 2,
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }else if(data.code === 0){
                            layer.closeAll('dialog');  //加入这个信息点击确定 会关闭这个消息框
                            layer.msg(data.msg, {
                                icon: 1,//成功的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                top.location.reload();
                            });
                        }
                    },
                    complete: function () {
                        layer.close(this.layerIndex);
                    },
                });
                layer.close(index);
            });
        });
        //导入数据
        function insertJson(version_number){
            //数据导入
            var url = "{U('Version/insertJson')}";
            var json_dir = $('#json_dir').val();
            if(json_dir == ""){
                layer.msg("请先上传文件", {
                    icon: 2,//失败的表情
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
                return;
            }
            $.ajax({
                url: url, type: "post", dataType: "json",
                data: { versionNum:version_number,json_dir:json_dir},
                beforeSend:function () {
                    this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
                },
                success:function(data){
                    if(data.code === 0){
                        //导入成功
                        layer.msg(data.msg, {
                            icon: 1,//成功的表情
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                            top.location.reload();
                        });
                    }else{
                        //导入失败
                        layer.msg(data.msg, {
                            icon: 2,//
                            time: 2000
                        });
                    }
                },
                complete: function () {
                    layer.close(this.layerIndex);
                },
            });
        }

        //更新到数据库
        $(".update").on("click",function () {
            //检测目录是否有文件
            var url = "{U('LolApi/checkFile')}";
            var json_dir = $('#json_dir').val();
            if(json_dir == ""){
                layer.msg("请先上传文件", {
                    icon: 2,//失败的表情
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
                return;
            }
            $.post(url,{ json_dir:json_dir},function(data){
                if(data.code === 0){
                    //有文件 先输入版本号
                    //最新版本号
                    var version_number = "{$newVersion}";
                    layer.prompt({ title: '请输入要导入的版本号，并确认',value:version_number, formType: 0}, function(version_number, index){
                        if(version_number == ""){
                            layer.msg("版本号不能为空", {
                                icon: 2,//失败的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }
                        if(version_number.length>50){
                            layer.msg("版本号过长", {
                                icon: 2,//失败的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }
                        layer.close(index);
                        //检测版本号是否存在
                        var url = "{U('Version/checkVersion')}";
                        $.post(url,{ version_number:version_number},function(data){
                            if(data.code === 0){
                                //新版本
                                insertJson(version_number);
                            }else{
                                //老版本 再次确认
                                layer.prompt({ title: '版本号：'+data.versionNum+'已经存在，您可以重新输入版本号，确认将更新数据到您当前输入的版本',value:data.versionNum, formType: 0}, function(version_number, index){
                                    layer.close(index);
                                    if(version_number == ""){
                                        layer.msg("版本号不能为空", {
                                            icon: 2,//失败的表情
                                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                        });
                                        return;
                                    }
                                    if(version_number.length>50){
                                        layer.msg("版本号过长", {
                                            icon: 2,//失败的表情
                                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                        });
                                        return;
                                    }
                                    insertJson(version_number);
                                });
                            }
                        });
                    });
                }else{
                    //文件夹为空
                    layer.msg(data.msg, {
                        icon: 2,
                        time: 2000
                    }, function(){
                        location.reload();
                    });
                }
            })
        });

        //复制版本
        $(".copy").on("click",function () {
            layer.confirm('确定复制此当前版本？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                layer.close(layer.index);
                layer.prompt({ title: '请输入要命名的版本号，并确认',formType: 0}, function(versionNumber, index){
                    if(versionNumber == ""){
                        layer.msg("版本号不能为空", {
                            icon: 2,//失败的表情
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                        return;
                    }
                    if(versionNumber.length>50){
                        layer.msg("版本号过长", {
                            icon: 2,//失败的表情
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                        return;
                    }
                    layer.close(index);
                    //检测版本号是否存在
                    var url = "{U('Version/checkVersion')}";
                    $.post(url,{ version_number:versionNumber},function(data){
                        if(data.code === 0){
                            //复制并创建新版本
                            var url = "{U('Version/copyVersion')}";
                            $.post(url,{ versionNumber:versionNumber},function(data){
                                if(data.code === 0){
                                    layer.msg(data.msg, {
                                        icon: 1,//成功的表情
                                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                    }, function(){
                                        location.reload();
                                    });
                                    return;
                                }else{
                                    layer.msg(data.msg, {
                                        icon: 2,//失败的表情
                                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                    }, function(){
                                        location.reload();
                                    });
                                    return;
                                }
                            });
                        }else{
                            //老版本 再次确认
                            layer.prompt({ title: '版本号：'+data.versionNum+'已经存在，您可以重新输入版本号，确认将当前版本的数据复制到您当前输入的版本', formType: 0}, function(versionNumber, index){
                                console.log(versionNumber);
                                if(versionNumber == "") {
                                    layer.msg("版本号不能为空", {
                                        icon: 2,//失败的表情
                                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                    }, function(){
                                        location.reload();
                                    });
                                    return;
                                }
                                if(versionNumber.length>50){
                                    layer.msg("版本号过长", {
                                        icon: 2,//失败的表情
                                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                    });
                                    return;
                                }
                                layer.close(index);
                                //检测版本号是否存在
                                var url = "{U('Version/checkVersion')}";
                                $.post(url,{ version_number:versionNumber},function(data){
                                    if(data.code === 0){
                                        //复制并创建新版本
                                        var url = "{U('Version/copyVersion')}";
                                        console.log("复制并创建新版本");
                                        $.post(url,{ versionNumber:versionNumber},function(data){
                                            if(data.code === 0){
                                                layer.msg(data.msg, {
                                                    icon: 1,//成功的表情
                                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                                }, function(){
                                                    location.reload();
                                                });
                                                return;
                                            }else{
                                                layer.msg(data.msg, {
                                                    icon: 2,//失败的表情
                                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                                }, function(){
                                                    location.reload();
                                                });
                                                return;
                                            }
                                        });
                                    }else{
                                        layer.msg("版本号已存在,无法复制", {
                                            icon: 2,//失败的表情
                                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                        }, function(){
                                            location.reload();
                                        });
                                    }
                                });
                            });
                        }
                    });
                });
            });
        });

        //英雄Tomba版本
        $("#heroTmoba").on("change",function () {
            var optionType = $('#heroTmoba option:selected') .val();
            if(optionType=='1'){
                $(".heroTmobaTextArea").show();
                $(".jsonHeroTmobaTips").show();
                $(".heroTmobaInput,.heroTmobaBtn").hide();
            }else if(optionType=='2'){
                $(".heroTmobaTextArea").hide();
                $(".heroTmobaInput,.heroTmobaBtn").css({
                    'display': 'inline-block'
                });
                $(".jsonHeroTmobaTips").hide();
            }else{
                return;
            }
        });

        //英雄Json版本
        $("#heroJson").on("change",function () {
            var optionType = $('#heroJson option:selected') .val();
            if(optionType=='1'){
                $(".heroJsonTextArea").show();
                $(".jsonHeroJsonTips").show();
                $(".heroJsonInput,.heroJsonBtn").hide();
            }else if(optionType=='2'){
                $(".heroJsonTextArea").hide();
                $(".heroJsonInput,.heroJsonBtn").css({
                    'display': 'inline-block'
                });
                $(".jsonHeroJsonTips").hide();
            }else{
                return;
            }
        });

        //道具Tomba版本
        $("#itemsTmoba").on("change",function () {
            var optionType = $('#itemsTmoba option:selected') .val();
            if(optionType=='1'){
                $(".itemsTmobaTextArea").show();
                $(".jsonItemsTmobaTips").show();
                $(".itemsTmobaInput,.itemsTmobaBtn").hide();
            }else if(optionType=='2'){
                $(".itemsTmobaTextArea").hide();
                $(".itemsTmobaInput,.itemsTmobaBtn").css({
                    'display': 'inline-block'
                });
                $(".jsonItemsTmobaTips").hide();
            }else{
                return;
            }
        });

        //道具Json版本
        $("#itemsJson").on("change",function () {
            var optionType = $('#itemsJson option:selected') .val();
            if(optionType=='1'){
                $(".itemsJsonTextArea").show();
                $(".jsonItemsJsonTips").show();
                $(".itemsJsonInput,.itemsJsonBtn").hide();
            }else if(optionType=='2'){
                $(".itemsJsonTextArea").hide();
                $(".itemsJsonInput,.itemsJsonBtn").css({
                    'display': 'inline-block'
                });
                $(".jsonItemsJsonTips").hide();
            }else{
                return;
            }
        });

        //皮肤Tomba版本
        $("#skinsTmoba").on("change",function () {
            var optionType = $('#skinsTmoba option:selected') .val();
            if(optionType=='1'){
                $(".skinsTmobaTextArea").show();
                $(".jsonSkinsTmobaTips").show();
                $(".skinsTmobaInput,.skinsTmobaBtn").hide();
            }else if(optionType=='2'){
                $(".skinsTmobaTextArea").hide();
                $(".skinsTmobaInput,.skinsTmobaBtn").css({
                    'display': 'inline-block'
                });
                $(".jsonSkinsTmobaTips").hide();
            }else{
                return;
            }
        });

        //点击按钮(添加内容)
        $(".heroTmobaBtn").on("click",function () {
            var str = "<div class=\"layui-col-row\"><input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 10px;\" type=\"text\" name=\"heroTmobaKey\" required  lay-verify=\"required\" placeholder=\"请输入Key值\" autocomplete=\"off\" class=\"layui-input heroTmobaInput\">";
            str+= "<input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 15px;\" type=\"text\" name=\"heroTmobaValue\" required  lay-verify=\"required\" placeholder=\"请输入Value值\" autocomplete=\"off\" class=\"layui-input heroTmobaInput\"><i class=\"delInp\">-</i></div>";
                // str += 
            $(".heroTmobaAdd").append(str);

            $(".delInp").click(function(){
                $(this).parent().remove();
            });
        });
        //点击按钮(添加内容)
        $(".heroJsonBtn").on("click",function () {
            var str = "<div class=\"layui-col-row\"><input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 10px;\" type=\"text\" name=\"heroJsonKey\" required  lay-verify=\"required\" placeholder=\"请输入Key值\" autocomplete=\"off\" class=\"layui-input heroJsonInput\">";
            str+= "<input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 15px;\" type=\"text\" name=\"heroJsonValue\" required  lay-verify=\"required\" placeholder=\"请输入Value值\" autocomplete=\"off\" class=\"layui-input heroJsonInput\"><i class=\"delInp\">-</i></div>";
            $(".heroJsonAdd").append(str);
            $(".delInp").click(function(){
                $(this).parent().remove();
            });
        });
        //点击按钮(添加内容)
        $(".itemsTmobaBtn").on("click",function () {
            var str = "<div class=\"layui-col-row\"><input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 10px;\" type=\"text\" name=\"itemsTmobaKey\" required  lay-verify=\"required\" placeholder=\"请输入Key值\" autocomplete=\"off\" class=\"layui-input itemsTmobaInput\">";
            str+= "<input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 15px;\" type=\"text\" name=\"itemsTmobaValue\" required  lay-verify=\"required\" placeholder=\"请输入Value值\" autocomplete=\"off\" class=\"layui-input itemsTmobaInput\"><i class=\"delInp\">-</i></div>";
            $(".itemsTmobaAdd").append(str);
            $(".delInp").click(function(){
                $(this).parent().remove();
            });
        });
        //点击按钮(添加内容)
        $(".itemsJsonBtn").on("click",function () {
            var str = "<div class=\"layui-col-row\"><input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 10px;\" type=\"text\" name=\"itemsJsonKey\" required  lay-verify=\"required\" placeholder=\"请输入Key值\" autocomplete=\"off\" class=\"layui-input itemsJsonInput\">";
            str+= "<input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 15px;\" type=\"text\" name=\"itemsJsonValue\" required  lay-verify=\"required\" placeholder=\"请输入Value值\" autocomplete=\"off\" class=\"layui-input itemsJsonInput\"><i class=\"delInp\">-</i></div>";
            $(".itemsJsonAdd").append(str);
            $(".delInp").click(function(){
                $(this).parent().remove();
            });
        });
        //点击按钮(添加内容)
        $(".skinsTmobaBtn").on("click",function () {
            var str = "<div class=\"layui-col-row\"><input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 10px;\" type=\"text\" name=\"skinsTmobaKey\" required  lay-verify=\"required\" placeholder=\"请输入Key值\" autocomplete=\"off\" class=\"layui-input skinsJsonInput\">";
            str+= "<input style=\"display: inline-block;width: 25%;margin: 0px 0px 10px 15px;\" type=\"text\" name=\"skinsTmobaValue\" required  lay-verify=\"required\" placeholder=\"请输入Value值\" autocomplete=\"off\" class=\"layui-input skinsJsonInput\"><i class=\"delInp\">-</i></div>";
            $(".skinsTmobaAdd").append(str);
            $(".delInp").click(function(){
                $(this).parent().remove();
            });
        });

        //删除列
        $(".delbtn").on("click",function () {
           $(this).parent().remove();
        });

        //监听提交
        form.on('submit(formDemo)', function(data){
            //数据收集
            var list = [];//创建数组
            var a1 = {};//创建对象
            var heroTmobaKeyArr = new Array();
            var heroTmobaValArr = new Array();
            var itemsTmobaKeyArr = new Array();
            var itemsTmobaValArr = new Array();
            var skinsTmobaKeyArr = new Array();
            var skinsTmobaValArr = new Array();
            var heroJsonKeyArr = new Array();
            var heroJsonValArr = new Array();
            var itemsJsonKeyArr = new Array();
            var itemsJsonValArr = new Array();
            //道具过滤
            a1.itemsFilterValue = $('#itemsFilterValue').val();
            //Tmoba英雄
            a1.heroTmobaType = $('#heroTmoba option:selected').val();
            if($('#heroTmoba option:selected').val() ==='1'){
                a1.heroTmobaTextArea = $("#heroTmobaTextArea").val();
            }else{
                $("input[name='heroTmobaKey']").each(function () {
                    heroTmobaKeyArr.push($(this).val());
                });
                $("input[name='heroTmobaValue']").each(function () {
                    heroTmobaValArr.push($(this).val());
                });
            }
            a1.heroTmobaKey = heroTmobaKeyArr;
            a1.heroTmobaValue = heroTmobaValArr;
            //Tmoba道具
            a1.itemsTmobaType = $('#itemsTmoba option:selected').val();
            if($('#itemsTmoba option:selected').val() === '1'){
                a1.itemsTmobaTextArea = $("#itemsTmobaTextArea").val();
            }else{
                $("input[name='itemsTmobaKey']").each(function () {
                    itemsTmobaKeyArr.push($(this).val());
                });
                $("input[name='itemsTmobaValue']").each(function () {
                    itemsTmobaValArr.push($(this).val());
                });
            }
            a1.itemsTmobaKey = itemsTmobaKeyArr;
            a1.itemsTmobaValue = itemsTmobaValArr;
            //Tmoba皮肤
            a1.skinsTmobaType = $('#skinsTmoba option:selected').val();
            if($('#skinsTmoba option:selected').val() === '1'){
                a1.skinsTmobaTextArea = $("#skinsTmobaTextArea").val();
            }else{
                $("input[name='skinsTmobaKey']").each(function () {
                    skinsTmobaKeyArr.push($(this).val());
                });
                $("input[name='skinsTmobaValue']").each(function () {
                    skinsTmobaValArr.push($(this).val());
                });
            }
            a1.skinsTmobaKey = skinsTmobaKeyArr;
            a1.skinsTmobaValue = skinsTmobaValArr;
            //Json英雄
            a1.heroJsonType = $('#heroJson option:selected').val();
            if($('#heroJson option:selected').val() === '1'){
                a1.heroJsonTextArea = $("#heroJsonTextArea").val();
            }else{
                $("input[name='heroJsonKey']").each(function () {
                    heroJsonKeyArr.push($(this).val());
                });
                $("input[name='heroJsonValue']").each(function () {
                    heroJsonValArr.push($(this).val());
                });
            }
            a1.heroJsonKey = heroJsonKeyArr;
            a1.heroJsonValue = heroJsonValArr;
            //Json皮肤
            a1.itemsJsonType = $('#itemsJson option:selected').val();
            if($("#itemsJson option:selected").val() === '1'){
                a1.itemsJsonTextArea = $("#itemsJsonTextArea").val();
            }else{
                $("input[name='itemsJsonKey']").each(function () {
                    itemsJsonKeyArr.push($(this).val());
                });
                $("input[name='itemsJsonValue']").each(function () {
                    itemsJsonValArr.push($(this).val());
                });
            }
            a1.itemsJsonKey = itemsJsonKeyArr;
            a1.itemsJsonValue = itemsJsonValArr;
            list.push(a1);//添加对象
            var j = JSON.stringify(list);//将对象转换为json

            //提示信息
            var str ="<div style='margin: 50px auto 0px;'>";
            str+="<div style='padding: 0px 20px 0px 20px;'>确定保存当前的导入前置配置么？</div>";
            str+="</div>";
            layer.open({
                type: 1,
                title: '版本数据导入保存确认',
                area: ['400px', '180px'] //自定义文本域宽高
                ,content: str //这里content是一个普通的String
                ,btn: ['确认', '取消']
                ,yes: function(index, layero){
                    //按钮【按钮一】的回调
                    var url =  "{U('DataImport/beforeImport')}";
                    $.post(url,{ filterInfo: j},function(data){
                        if(data.status == 'error'){
                            layer.msg(data.msg, {
                                icon: 2,//失败的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                location.reload();
                            });
                        }else if(data.status == 'success'){
                            layer.msg(data.msg, {
                                icon: 1,//成功的表情
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                location.reload();
                            });
                        }
                    })
                }
                ,btn2: function(index, layero){
                    //按钮【按钮二】的回调
                    //return false 开启该代码可禁止点击该按钮关闭
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
